package com.ruoyi.web.controller.ltd_web;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.ltd_web.domain.LtdContent;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ltd_web.domain.LtdHistory;
import com.ruoyi.ltd_web.service.ILtdHistoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 公司发展历史信息Controller
 *
 * @author ruoyi
 * @date 2024-12-17
 */
@RestController
@RequestMapping("/system/history")
public class LtdHistoryController extends BaseController
{
    @Autowired
    private ILtdHistoryService ltdHistoryService;

    /**
     * 查询公司发展历史信息列表
     */
    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(LtdHistory ltdHistory)
    {
        startPage();
        List<LtdHistory> list = ltdHistoryService.selectLtdHistoryList(ltdHistory);
        return getDataTable(list);
    }

    /**
     * 导出公司发展历史信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:history:export')")
    @Log(title = "公司发展历史信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LtdHistory ltdHistory)
    {
        List<LtdHistory> list = ltdHistoryService.selectLtdHistoryList(ltdHistory);
        ExcelUtil<LtdHistory> util = new ExcelUtil<LtdHistory>(LtdHistory.class);
        util.exportExcel(response, list, "公司发展历史信息数据");
    }

    /**
     * 获取公司发展历史信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:history:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ltdHistoryService.selectLtdHistoryById(id));
    }

    /**
     * 新增公司发展历史信息
     */
    @PreAuthorize("@ss.hasPermi('system:history:add')")
    @Log(title = "公司发展历史信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LtdHistory ltdHistory)
    {
        return toAjax(ltdHistoryService.insertLtdHistory(ltdHistory));
    }

    /**
     * 修改公司发展历史信息
     */
    @PreAuthorize("@ss.hasPermi('system:history:edit')")
    @Log(title = "公司发展历史信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LtdHistory ltdHistory)
    {
        return toAjax(ltdHistoryService.updateLtdHistory(ltdHistory));
    }

    /**
     * 删除公司发展历史信息
     */
    @PreAuthorize("@ss.hasPermi('system:history:remove')")
    @Log(title = "公司发展历史信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ltdHistoryService.deleteLtdHistoryByIds(ids));
    }


    /**
     * 列表不分页
     */
    @Anonymous
    @GetMapping("/list_status/")
    public AjaxResult list_status(LtdHistory ltdHistory)
    {
        return ltdHistoryService.selectLtdHistoryListByStatus(ltdHistory);
    }

    /**
     * 发展历史删除--状态修改
     */
    @PreAuthorize("@ss.hasPermi('system:history:edit')")
    @Log(title = "发展历史删除--状态修改", businessType = BusinessType.UPDATE)
    @PutMapping("/changeStatus")
    public AjaxResult changeStatus(@RequestBody LtdHistory ltdHistory)
    {
        return toAjax(ltdHistoryService.updateLtdHistory(ltdHistory));
    }
}
